Deduplicate repo+sysroot syncfs logic
authorColin Walters <walters@verbum.org>
Thu, 21 Aug 2025 09:57:03 +0000 (11:57 +0200)
committerColin Walters <walters@verbum.org>
Mon, 25 Aug 2025 15:06:16 +0000 (11:06 -0400)
commitcb369f71429b6122949668ce6fbaf9540b90ceca
treec2757e34c732aea52e63ab5a894aba754f69d659
parent971a037ea0d792e7535f3c62cb031f5b1b5ad2dd
Deduplicate repo+sysroot syncfs logic

This is a followup to https://github.com/ostreedev/ostree/pull/3504/commits/6e5a27a29d33d50a2a4380c406405435d919b6b4
which I believe is correct as is. However, we already have a file
descriptor open for the ostree repo, which *must* be on
the same filesystem as `/sysroot/ostree` (the deployment
code forces hardlinking today).

It's hence cleaner to reuse that extant fd instead of opening
a new one - we know we did writes to that fd.

But going farther here, there already is logic to use syncfs
for the repo when downloading objects (in a common case
we actually syncfs twice).

Since these are really the same operation, unify them:

- Add journaling to the repo one syncfs case
- Change the sysroot case to just call it
- Since we log consistently to the journal for all syncfs/fsfreeze
  operations now, drop the SyncStats bits which was a way
  to add info about that to a later journal message

Additionally, let's add an extra check when we're
opening the repo that it's on the same device just on general
principle.

Signed-off-by: Colin Walters <walters@verbum.org>
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c
src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot.c
tests/kolainst/destructive/staged-deploy.sh